//
//  DestinationTripTableViewCell.m
//  HappyTrip
//
//  Created by yuxuesong on 15-3-24.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "DestinationTripTableViewCell.h"

@implementation DestinationTripTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.picImage = [[UIImageView alloc] init];
        _picImage.clipsToBounds = YES;
        _picImage.layer.cornerRadius = 10;
        _picImage.contentMode = UIViewContentModeScaleAspectFill;
        [self.contentView addSubview:_picImage];
        [_picImage release];
        
        self.titlePic = [[UIImageView alloc] init];
        [self.contentView addSubview:_titlePic];
        [_titlePic release];
        self.titleLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_titleLabel];
        [_titleLabel release];
        
        self.day_countPic = [[UIImageView alloc] init];
        [self.contentView addSubview:_day_countPic];
        [_day_countPic release];
        self.day_countLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_day_countLabel];
        [_day_countLabel release];
        
        self.wayPic = [[UIImageView alloc] init];
        [self.contentView addSubview:_wayPic];
        [_wayPic release];
        self.waypoint_recommendationsLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_waypoint_recommendationsLabel];
        [_waypoint_recommendationsLabel release];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat width = self.bounds.size.width;
    CGFloat height = self.bounds.size.height;
    _picImage.frame = CGRectMake(10, 2, width - 10 * 2, height - 2 * 2);
    _titlePic.frame = CGRectMake(width / 20, height / 20 + height / 3 / 2 - 8, 17, 17);
    _titleLabel.frame = CGRectMake(width / 20 + 25, height / 20, width - (width / 20  + 25) * 2, height / 3);
    _day_countPic.frame = CGRectMake(width * 2 / 3 - 30, height / 9 * 6, 12, 12);
    _day_countLabel.frame = CGRectMake(width * 2 / 3 - 10, height / 9 * 6, width / 3, height / 9);
    _wayPic.frame = CGRectMake(width * 2 / 3 - 30, height / 9 * 7 + 2, 12, 12);
    _waypoint_recommendationsLabel.frame = CGRectMake(width * 2 / 3 - 10, height / 9 * 7 + 2, width / 3, height / 9);
}

- (void)setDesTripsObject:(DesTripsObject *)desTripsObject
{
    if (_desTripsObject != desTripsObject) {
        [_desTripsObject release];
        _desTripsObject = [desTripsObject retain];
    }
    [_picImage setImageWithURL:[NSURL URLWithString:self.desTripsObject.cover_image_default] placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
    _titlePic.image = [UIImage imageNamed:@"iconfont-huantu.png"];
    _titleLabel.text = self.desTripsObject.name;
    _day_countPic.image = [UIImage imageNamed:@"iconfont-16shixian.png"];
    _day_countLabel.text = [NSString stringWithFormat:@"用时: %@ 天", [self.desTripsObject.day_count stringValue]];
    _wayPic.image = [UIImage imageNamed:@"iconfont-qulvxing.png"];
    _waypoint_recommendationsLabel.text = [[[[self.desTripsObject.waypoints stringValue] stringByAppendingString:@" 足迹  /  "] stringByAppendingString:[self.desTripsObject.recommendations stringValue]] stringByAppendingString:@" 喜欢"];
    _titleLabel.font = [UIFont systemFontOfSize:15];
    _day_countLabel.font = [UIFont systemFontOfSize:12];
    _waypoint_recommendationsLabel.font = [UIFont systemFontOfSize:12];
    _titleLabel.numberOfLines = 0;
//    [self.titleLabel sizeToFit];
    _titleLabel.textColor = [UIColor whiteColor];
    _waypoint_recommendationsLabel.textColor = [UIColor whiteColor];
    _day_countLabel.textColor = [UIColor whiteColor];
    
}

- (void)dealloc
{
    [_picImage release];
    [_titlePic release];
    [_titleLabel release];
    [_day_countPic release];
    [_day_countLabel release];
    [_wayPic release];
    [_waypoint_recommendationsLabel release];
    [super dealloc];
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
